package com.scedu.service.impl;

import com.scedu.entity.Employee;
import com.scedu.repository.EmployeeRepository;
import com.scedu.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service //业务层
@Transactional //事务控制
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeRepository employeeRepository;
    @Override
    public Integer save(Employee employee) {
        return employeeRepository.insert(employee);
    }

    @Override
    public Integer update(Employee employee) {
        return employeeRepository.updateById(employee);
    }

    @Override
    public List<Employee> findAll() {
        //参数是一个wapper，是一个条件构造器
        return employeeRepository.selectList(null);
    }
}
